package com.example.oasystem.service.impl;

import com.example.oasystem.dao.notice.AoaNoticeListDao;
import com.example.oasystem.entity.notice.AoaNoticeListOfChen;
import com.example.oasystem.entity.notice.AoaNoticeUserRelation;
import com.example.oasystem.entity.notice.NoticeDTO;
import com.example.oasystem.entity.user.AoaUser;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl {
    @Autowired
    AoaNoticeListDao aoaNoticeListDao;
    public PageInfo<NoticeDTO> findNoticeLimit(int uid, int pageNum, int PageSize) {
        PageHelper.startPage(pageNum, PageSize);
        List<NoticeDTO> allRole = aoaNoticeListDao.findNotice2(uid,"");
        PageInfo<NoticeDTO> pageInfo = new PageInfo<NoticeDTO>(allRole);
        return pageInfo;
    }
    public PageInfo<NoticeDTO> findNoticeLimitByText(int uid,int pageNum, int PageSize, String text) {
        PageHelper.startPage(pageNum, PageSize);
        List<NoticeDTO> rolelist = aoaNoticeListDao.findNotice2(uid,text);
        PageInfo<NoticeDTO> pageInfo = new PageInfo<NoticeDTO>(rolelist);
        return pageInfo;
    }
    public List<AoaUser> selectSonUser(int userId){
        return aoaNoticeListDao.selectSonUser(userId);
    }
    public List<AoaNoticeUserRelation> findRelationByNoticeId(int noticeId){
        return aoaNoticeListDao.findRelationByNoticeId(noticeId);
    }
    public AoaNoticeListOfChen selectNotice(int id){
        return aoaNoticeListDao.selectNotice(id);
    }
    public int updateRead(int noticeId,int uid){
        return aoaNoticeListDao.updateRead(noticeId,uid);
    }
    public int updateReadByRelation(int id){
        return aoaNoticeListDao.updateReadByRelation(id);
    }
    public int deleteRelatioByRelationId(int id){
        return aoaNoticeListDao.deleteRelatioByRelationId(id);
    }
    public int insertNoticeRelation(int noticeId,int uid){
        return aoaNoticeListDao.insertNoticeRelation(noticeId,uid);
    }

}
